<!-- 删除确认对话框 -->
<div class="modal fade" id="delDialog" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
    <div class="modal-dialog" role="document">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
                <h4 class="modal-title" id="myModalLabel">删除确认</h4>
            </div>
            <div class="modal-body">
                <p>确定删除此记录吗？</p>
            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-default" data-dismiss="modal">取 消</button>
                <button type="button" class="btn btn-primary" id="myModalLabelDelYes">确 定</button>
            </div>
        </div>
    </div>
</div>

<script type="text/javascript">
    var doDelete = function (id) {
        var dtd = $.Deferred(),
                myId = id || null;
        $.ajax({
            url: "${deleteURL!}",
            cache:false,
            data:{
                id:myId
            },
            dataType:"json"
        }).done(function(json) {
            dtd.resolve(json);
        });
        return dtd.promise();
    };
    $(".deleterow").off("click").on("click",function(){
        var $thisdel = $(this),
                mmd = $("#delDialog"),
                mmdmb = mmd.find('.modal-body'),
                mmldy = $("#myModalLabelDelYes");
        var id = $(this).attr("id");
        mmd.modal();
        mmldy.off("click").on("click", function () {
            $.when(doDelete(id))
                    .then(function (json) {
                        if(json){
                            window.location.reload();
                        }else{
                            alert("删除失败.请重试！");
                        }
                    });
        });

    });
</script>
